<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div id="dialog-message">
	<div style="height:400px;overflow:auto;">
		<ul id="TeacherTree" class="ztree"></ul>
	</div>
	<div>
		<hr>
		当前老师所在学校：<div id="teacherAndClassButton" class="btn btn-info"></div>
	</div>
</div>
<script type="text/javascript">
(function(){
	var arr = new Array();
	var callbackTree ={
			click:function(event, treeId, treeNode){	
				  arr = new Array();
				  var object = new Object();
				  object.table_id = treeNode.table_id; 
				  object.type =treeNode.type;
				  arr.push(object);
				  $("#teacherAndClassButton").text(treeNode.pName);
				  loadparent(treeNode); 
			}
	};
	//递归得到自己的上级
	function loadparent(node){
		var pnode =node.getParentNode();
		if(pnode!=null){
			  var object = new Object();
			  object.table_id = pnode.table_id; 
			  object.type =pnode.type;
			  arr.push(object);
			  loadparent(pnode);
		}
	};
	
	var treeObj =window.myjs.loadTree("TeacherTree",callbackTree);
	function addTeacherAddClass(contrl){
			var url ="${pageContext.request.contextPath}/edu/sysClassAction.do?method=addTeacherAddClass&r="+Math.random();
			$.ajax({
			   type: "POST",
			   url: url,
			   data: {teacherId:"${param.table_id}",arr:obj2str(arr)},
			   dataType:'json',
			   success: function(msg){
			       alert(msg.message);
			       if(msg.code==1){
			    	   $(contrl).dialog('destroy'); 
					   $("#user_include").html("");
			       }
			   }
			});
			 
	};
	$(function(){
		
	});
	window.TeacherandClassAdd={};
	window.TeacherandClassAdd.addTeacherAddClass =addTeacherAddClass;
})();
</script> 